#include <iostream>
#include <memory>
#include <vector>
using std::cout;
using std::endl;
using std::vector;
using std::unique_ptr;

class Point{
public:
    Point(int x,int y)
    :_x(x)
    ,_y(y)
    {
        cout << "Point(int x, int y)" <<endl;
    }
    ~Point(){
        cout << "~Point(int x, int y)" << endl;
    }
    void print(){
        cout <<"("<< _x << "," << _y << ")" << endl;
    }
private:
    int _x,_y;
};

void test(){
    vector<unique_ptr<Point>> vec;
    unique_ptr<Point> up(new Point(1,2));
    //vec.push_back(up); //error: unique_ptr禁止拷贝赋值
    vec.push_back(std::move(up));
    vec.push_back(unique_ptr<Point>(new Point(3,4)));
    vec.push_back(unique_ptr<Point>(new Point(5,6)));
    for(auto & up_temp : vec){
        up_temp->print();
    }
}

int main()
{
    

    test ();
    return 0;
}

